package name.fowler.refactoring.simplestore.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Customer {
    private final String name;
    private final List<Rental> rentals = new ArrayList<Rental>();

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void addRental(Rental rental){
        rentals.add(rental);
    }

    public List<Rental> getRentals() {
        return Collections.unmodifiableList(rentals);
    }

    public double getTotalAmount() {
        double result = 0;
        for (Rental rental : rentals) {
            result += rental.getAmount();
        }
        return result;
    }

    public int getTotalBonus() {
        int result = 0;
        for (Rental rental : rentals) {
            result += rental.getBonus();
        }
        return result;
    }
}

